const express = require('express');

const app = express();
const static = require('./middleware/static')
const bodyParser = require('./middleware/body-parser')

app.use(static(__dirname)); // 中间是一个函数的好处就是可以接受用户的参数
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
// 本身有一个中间件 express.static

app.get('/user', function (req, res) {
    // console.log(req.path, req.query)
    res.sendFile(require('path').resolve(__dirname, 'index.js'))
})
app.post('/user', function (req, res) {
    // console.log(req.path, req.query)
    res.send(req.body)
})
app.listen(3000);